//处理道具及碰撞的脚本
cc.Class({
    extends: cc.Component,
    _leftTime:0,
    _leftTime:0,
    _callback:null,

    properties: {
        num:cc.Label
    },
    
    startLeft:function(left,callback) {
        this.num.string=parseInt(left);
        this._leftTime=left;
        this._passTime=0;
        this._callback=callback;

        var ctx = this.getComponent(cc.Graphics);
        ctx.clear();
        ctx.strokeColor = cc.hexToColor('#ffffff');
        ctx.arc(0,0,60,0,2*Math.PI);
        ctx.stroke();
    },

    resetInfo:function(){
        this._leftTime=0;
        this._leftTime=0;
        this._callback=null;
    },

    // LIFE-CYCLE CALLBACKS:
    onLoad() {
       
        
    },

    update(dt){
        //开始
        if(this._leftTime>0){
            //开始计时并且
            let left=this._leftTime-this._passTime;
            if(left>=0){
              //设置字体
              this.num.string=Math.round(left);
              var ctx = this.getComponent(cc.Graphics);
              ctx.strokeColor = cc.hexToColor('#ff0000');
              ctx.arc(0,0,60,0,2*Math.PI*(this._passTime/this._leftTime),true);
              ctx.stroke();
              this._passTime+=dt;
            }else{
                if(this._callback){
                    this._callback();
                } 
                this.resetInfo();
            }
        }
    }
});
